package com.vanzo.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Button;

import com.vanzo.encryption.R;

/**
 * Created by yaofang on 2018/3/5.
 */

public class ButtonListener extends Button {
    public ButtonListener(Context context) {
        super(context);
    }

    public ButtonListener(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ButtonListener(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()){
            case MotionEvent.ACTION_DOWN :
                Log.d("yaofang" , "按下......:");
                setBackgroundColor(getResources().getColor(R.color.colorPrimary));
                break;
            case MotionEvent.ACTION_UP :
                Log.d("yaofang" , "抬起......:");
                setBackground(getResources().getDrawable(R.mipmap.ic_launcher));
                break;

        }



        return super.onTouchEvent(event);
    }
}
